package Messages;

import java.io.IOException;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the delete supplier from DB
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageDeleteSupp {
	private ConnectionToClient client ;
	private String[] str; 
/**
 * constructor of this class 
 * @param str
 * @param client
 */
	public MessageDeleteSupp(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 	
	}
	/**
	 * This method delete supplier from the DB 
	 * @throws SQLException
	 * @throws IOException
	 */
	public void DeleteSupp() throws SQLException, IOException{
		SQLConnection sc = new SQLConnection();

		java.sql.PreparedStatement ps=sc.getConnection().prepareStatement("DELETE FROM db.suppliers where idsuppliers = ?;");
		ps.setString(1,str[1]);
		ps.executeUpdate();
		ps.close();
		client.sendToClient("DeleteSuppliers");
	}
}
